//
//  TwoViewController.m
//  颜色block
//
//  Created by missummer on 15-4-10.
//  Copyright (c) 2015年 missummer. All rights reserved.
//

#import "TwoViewController.h"

@interface TwoViewController ()

@end

@implementation TwoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor   = [UIColor whiteColor];
    UIButton * button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(100, 100, 100, 100);
    button.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(push) forControlEvents:UIControlEventTouchUpInside];
}

- (void)push{
    if (self.changeColor) {
        self.changeColor();
    }
    if (self.returnTextBlock) {
        self.returnTextBlock(@"imfine");
    }
    if (self.returnColorBlock) {
        self.returnColorBlock([UIColor redColor]);
    }
    if (self.returnColorAndTextBlock) {
        self.returnColorAndTextBlock([UIColor purpleColor] , [UIColor blackColor] , @"imfine");
    }
    
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)returnColorAndText:(ReturnColorAndText)block
{
    self.returnColorAndTextBlock = block;
}

- (void)returnText:(ReturnStr)block
{
        self.returnTextBlock = block;
}
- (void)returnColor:(ReturnColorBlock)block
{
    self.returnColorBlock = block;
}

@end
